package com.pojo;

import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        System.out.println("=============调用MyBeanFactoryPostProcessor的postProcessBeanFactory============");

        BeanDefinition bd = beanFactory.getBeanDefinition("myTestBean");
        System.out.println("属性值:" + bd.getPropertyValues().toString());
        MutablePropertyValues pv = bd.getPropertyValues();
        if (pv.contains("remark")) {
            pv.addPropertyValue("remark", "修改后备注");
        }
        bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
    }
}
